/*
 Author: Vladimir Kharlampidi, The iDangero.us
 */
document.createElement('header');
document.createElement('footer');

$(function() {

    //Main Swiper
    var swiper = new Swiper('.swiper1', {
        pagination: '.pagination1',
        loop: true,
        speed: 1200,
        moveStartThreshold: 100,
        grabCursor: true, onSlideChangeStart: function() {
//            Do something when you touch the slide
//            alert(swiper.activeSlide);

//            $(".description").hide();
            $(".more_info").slideUp();
            Active = false;

//            $("div#down").hide();
//            Active = false;
//            intervalID.delay(5000);

        },
        onSlideChangeEnd: function() {
//            Do something when you touch the slide
//            alert(swiper.activeSlide);
//            $(".description").show();
//            $("div#down").show();
$("div#down").delay(800).show(0);
          

        }

    });
    //Navigation arrows
    $('.arrow-left').click(function(e) {
        e.preventDefault()
        swiper.swipePrev()
    });
    $('.arrow-right').click(function(e) {
        e.preventDefault()
        swiper.swipeNext()


    });
    //Clickable pagination
    $('.pagination1 .swiper-pagination-switch').click(function() {
        swiper.swipeTo($(this).index())
    })
    //Movies App



    var allowMovieClick = true
    var swiperMControl = $('.mc-control').swiper({
        mode: "horizontal",
        scrollContainer: true,
        onTouchMove: function() {
            allowMovieClick = false
        },
        onTouchEnd: function() {
            setTimeout(function() {
                allowMovieClick = true
            }, 100)
        }
    });
    $('.mc-control img').bind('mousedown', function(e) {
        e.preventDefault()
    })
    $('.mc-control img').bind('click', function(e) {
        e.preventDefault()
        if (!allowMovieClick)
            return;
        var index = $(this).index()
        swiper.swipeTo(index)
        $('.mc-control .active').removeClass('active')
        $(this).addClass('active')
    })


})

